package com.home.admin.base;

import com.home.base.core.framework.msg.ServerResponse;
import com.home.common.annotation.CheckApiClient;
import com.home.common.constants.client.ClientConstant;
import com.home.common.framework.core.controller.BaseController;
import com.home.common.model.TreeNode;
import com.home.webapp.base.entity.BaseRoleUser;
import com.home.webapp.base.service.BaseRoleUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


/**
 * Description: 用户角色 controller
 * Created by 王大宸 on 2020-10-05 23:28:38
 * Created with IntelliJ IDEA.
 */
@Controller
@RequestMapping(value = "/base/role/user")
@CheckApiClient(title = "用户角色", clientId = ClientConstant.CLIENT_WEB)
public class BaseRoleUserController extends BaseController<BaseRoleUserService, BaseRoleUser, String> {
    private static final Logger logger = LoggerFactory.getLogger(BaseRoleUserController.class);

    /***
     * 功能说明：获取用户角色树
     *
     * @author 王大宸
     * @date 2020/10/8 15:26
     * @param userId userId
     * @return com.home.common.framework.msg.ServerResponse<java.util.List < java.util.Map < java.lang.String, java.lang.Object>>>
     */
    @GetMapping(value = "/zTree/{userId}")
    @ResponseBody
    public ServerResponse<List<TreeNode>> roleTree(@PathVariable("userId") String userId) throws Exception {
        return ServerResponse.okData(baseService.roleTree(userId));
    }

}